//
//  NSMutableArray+Extension.m
//  learnProject
//
//  Created by 吴斌 on 2022/9/19.
//

#import "NSMutableArray+Extension.h"
#import <objc/runtime.h>

@implementation NSMutableArray (Extension)

+ (void)load
{
//   类簇:NSString、NSArray、NSDictionay、真实类型是其他类型
    
    Class cls = NSClassFromString(@"__NSArrayM");
    
    Method method1 = class_getInstanceMethod(cls, @selector(insertObject:atIndex:));
    Method method2 = class_getInstanceMethod(cls, @selector(wb_insertObject:atIndex:));
    
    method_exchangeImplementations(method1, method2);
}

- (void)wb_insertObject:(id)anObject atIndex:(NSUInteger)index
{
//    解决值为nil报错问题
    if (anObject == nil) return;
    
    [self wb_insertObject:anObject atIndex:index];
}

@end
